<%@ page isELIgnored="false" %><%--isELIgnored=true禁用EL表达式--%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!-- JSTL标签库是一个JSP标签的集合，封装了许多jsp应用程序通用的核心功能-->
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/layui-v2.6.13/layui/css/layui.css"/>
    <script src="${pageContext.request.contextPath}/js/jquery.min-2.1.1.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/layui-v2.6.13/layui/layui.js"></script>
    <style>
        #d1{
            background-color: sandybrown;
            margin-left: 1200px;
            margin-top: 200px;
            width: 400px;
            height: 500px;
        }
        #d2{
            padding-top: 50px;
        }
        #d3{
            padding-top: 30px;
        }
        #d4{
            padding-top: 30px;
        }
        .layui-btn{
            width: 150px;
        }
    </style>
</head>
<body>
<div id="d1">
    <form class="layui-form" action="">
        <div class="layui-form-item" id="d2">
            <label class="layui-form-label">账户：</label>
            <div class="layui-input-inline">
                <input type="text" name="mName" placeholder="请输入用户名" class="layui-input" id="mName"value="admin">
            </div>
        </div>
        <div class="layui-form-item" id="d3">
            <label class="layui-form-label">密码：</label>
            <div class="layui-input-inline">
                <input type="password" name="mPass" placeholder="请输入密码" class="layui-input" id="mPass" value="123">
            </div>
        </div>
    </form>
    <div class="layui-form-item" id="d4">
        <div class="layui-input-block">
            <button class="layui-btn" onclick="login()">登录</button>
        </div>
    </div>
</div>
</body>
<script>
    function login(){
        //登录参数验证
        var mName = $("#mName").val();
        if(mName == ''){
            alert("请输入用户名");
            return;
        }
        var mPass = $("#mPass").val();
        if(mPass == ''){
            alert("请输入密码");
            return;
        }
        var params = "mName="+mName+"&mPass="+mPass;
        //提交登录信息
        $.ajax({
            url: "http://localhost:8080/shopping/manager/adminLoginCheck",
            data: params,
            type: "post",
            success:function(str){
                console.info(str);
                if(str != '0'){
                    alert("登录成功");
                    //跳主页
                    window.location.href="http://localhost:8080/shopping/manager/loginAdmin?id="+str;
                } else {
                    alert("登陆失败")
                }
            }
        });
    }
</script>
</html>
